#ifndef WSYPLANE_H
#define WSYPLANE_H

#include "QtGui/QOpenGLFunctions"
#include "geometry/math3d.h"

/** 王诗阳面对象 */
class WSYPlane : public QObject {
    Q_OBJECT
public:
    WSYPlane(GLfloat *vertex, GLfloat *normal) {
        this->vertex = Math3D::newInstanceWithOldVector(vertex);
        this->normal = Math3D::newInstanceWithOldVector(normal);
    }
    ~WSYPlane() {}
    /** 设置新的节点 */
    virtual void setVertex(float x, float y, float z) {
        Math3D::setNewValue(x, y, z, vertex);
    }
    /** 设置新的法向量 */
    virtual void setNormal(float dx, float dy, float dz) {
        Math3D::setNewValue(dx, dy, dz, normal);
    }
    virtual GLfloat *getVertex() {
        return vertex;
    }
    virtual GLfloat *getNormal() {
        return normal;
    }
    virtual GLfloat getDValue() {
        GLfloat A = normal[0], B = normal[1], C = normal[2];
        GLfloat x0 = vertex[0], y0 = vertex[1], z0 = vertex[2];
        return -(A * x0 + B * y0 + C * z0);
    }
private:
    GLfloat *vertex, *normal;
};


#endif // WSYPLANE_H
